package com.gin.no_gay_alliance.viewmodel;

import com.gin.nga.enums.SubForumType;
import com.gin.nga.response.field.ForumInfo;

/**
 * 版面搜索结果
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/8/4 17:37
 **/
public class ForumSearchResult extends EntryData {
    /**
     * 父版面id
     */
    public Long parentId;
    /**
     * 父版面名称
     */
    public String parentName;
    /**
     * 父版面图标地址
     */
    public String parentIcon;

    public ForumSearchResult(ForumInfo forumInfo) {
        if (forumInfo.getColTid() != null && forumInfo.getColTid() != 0) {
            this.id = forumInfo.getColTid();
            this.type = SubForumType.COL;
        } else {
            this.id = forumInfo.getForumId();
            this.type = SubForumType.FORUM;
        }
        this.name = forumInfo.getName();
        this.icon = forumInfo.getBigIconUrl();

        ForumInfo.Parent parent = forumInfo.getParent();
        if (parent != null) {
            this.parentId = parent.getForumId();
            this.parentName = parent.getName();
            this.parentIcon = parent.getBigIconUrl();
        }
    }

    public ForumSearchResult() {
    }
}
